package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootYys;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Getter
@Setter
public class FootYysSearchForm extends SearchForm implements Serializable {
    private static final long serialVersionUID = 8090668615941861551L;
    protected String userName;
    protected Long userId;
    protected Integer jf;

    public Example buildSearchCommond() {
        Example example = new Example(FootYys.class);
        Example.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(userName)) {
            criteria.andLike("userName", "%" + userName + "%");
        }
        if (jf != null) {
            criteria.andEqualTo("jf", jf);
        }
        if (userId != null) {
            criteria.andEqualTo("userId", userId);
        }
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("jf").desc().orderBy("sl").desc().orderBy("bscc").desc().orderBy("s").desc()
                .orderBy("p").desc().orderBy("f").desc();
        return example;
    }

}
